package com.guigusuqi.activiti.controller;


import com.guigusuqi.activiti.dto.BPMNFileDTO;
import com.guigusuqi.activiti.dto.CompleteTaskDTO;
import com.guigusuqi.activiti.dto.TbFlowInsertDTO;
import com.guigusuqi.activiti.service.TbFlowService;
import com.guigusuqi.commonutils.utils.GetTokenByAuthorizationUtils;
import com.guigusuqi.commonutils.vo.Result;
import com.guigusuqi.user.entity.LoginUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author suqi
 * @since 2023-06-15
 */
@RestController
@RequestMapping("/flow")
@Api(tags = {"部署流程管理"})
public class TbFlowController
{
    @Resource
    private TbFlowService tbFlowService;

    @GetMapping("deleteAllFlow")
    @ApiOperation("删除所有部署流程")
    public Result<Boolean> deleteAllFlow()
    {
        tbFlowService.deleteAllFlow();
        return Result.success("删除成功");
    }

    @PostMapping("createTbFlow")
    @ApiOperation("创建部署流程")
    public Result<Boolean> createTbFlow(@Valid @RequestBody TbFlowInsertDTO tbFlowInsertDTO)
    {
        tbFlowService.createTbFlow(tbFlowInsertDTO);
        return Result.success("创建成功");
    }

    @PostMapping("getBPMNFile")
    @ApiOperation("获取bpmn文件信息")
    public Result<Boolean> getBPMNFile(@Valid @RequestBody BPMNFileDTO bpmnFileDTO)
    {
        tbFlowService.getBPMNFile(bpmnFileDTO);
        return Result.success(true);
    }

    @ApiOperation("通过部署id删除该部署流程")
    @PostMapping("deleteProcessByFlowKey/{flowKey}")
    public Result<Boolean> deleteProcessByDeploymentId(@PathVariable String flowKey)
    {
        tbFlowService.deleteProcessByDeploymentId(flowKey);
        return Result.success("删除该部署流程成功!");
    }
}

